// pages/home/home.js
import WxValidate from "../../utils/wxValidate.js";
var api = require("../../utils/api");
var cf = require("../../config.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopBack: {},
    codeNum: "",
    isShow: true,//隐藏
  },
  onLoad: function (options) {
    this.setData({
      shopBack: {
        linkman: options.takePerson,//收货人
        linktel: options.linktel,//联系电话
        addr: options.addrs,//收货地址
        buildNo: options.buildNo,//详细地址
        id: options.id
      }
    })
  },

  handleAddr() {
    // let userInfoId = this.data.shopBack.userInfoId
    api.setDefault({
      cityId: wx.getStorageSync("cityId"),
      flag: 1,
      addressType: 2,
      openId: wx.getStorageSync("openId"),
      id: this.data.shopBack.id
      // userInfoId: userInfoId
    })
      .then(res => {
        wx.showToast({
          title: '设置成功',
          duration: 1500,
          success: () => {
            let pages = getCurrentPages();//当前页面栈
            if (pages.length > 1) {
              let beforePage = pages[pages.length - 2];//获取上一个页面实例对象
              beforePage.addrs();//触发父页面中的方法
              wx.navigateBack()
            }
          }
        })
      })
  }
})